package comparator;

import java.util.*;

public class ComparatorExp{
	public static void main(String[] args) {
		LinkedList<Anonymous> linkedList=new LinkedList<>();
		Anonymous[] anonymous;
		Scanner scanner=new Scanner(System.in);
		System.out.println("请输入数字 输入其他字符会退出键入");
		while (true){
			try {
				linkedList.add(new Anonymous(scanner.nextInt()));
			}
			catch (InputMismatchException inputMismatchException){
				break;
			}
		}
		anonymous=linkedList.toArray(new Anonymous[0]);
		Anonymous.sort(anonymous);
	}
}
class Anonymous implements Comparable<Anonymous>{
	int anInt;
	static void sort(Anonymous[] anonymous){
		Arrays.sort(anonymous);
		for (Anonymous anonymous1:anonymous) System.out.println(anonymous1.anInt);
	}
	public Anonymous(int anInt) {
		this.anInt = anInt;
	}

	@Override
	public int compareTo(Anonymous o) {
		if (o==null)return 0;
		else 		return Integer.compare(this.anInt,o.anInt);
	}
}
